package com.shop.admin.dao.user;

import com.shop.jpa.BaseDao;
import com.shop.domain.user.UserBill;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface UserBillDao extends BaseDao<UserBill, Long> {

    //未中奖 添加佣金记录流水
    @Modifying(clearAutomatically = true)
    @Query(value = "insert into t_user_bill(uid,title,mark,relation_id,table_name,initial_price,price,refresh_price,pm,type,create_time)  " +
            "select p.uid,'抢购未中奖',concat('抢购未中奖，返回商品金额',c.price,'元'),p.id,'snap_not_prize',u.balance,c.price,u.balance+c.price,0,1,now() from t_store_snap_pink p  " +
            "left join t_user u on u.id = p.uid left join t_store_snap_pink_config c on c.id = p.pink_id " +
            "where p.pink_id=?1 and p.pink_status = 2 and p.`status`=1 and p.`is_deleted` =0",nativeQuery = true)
    int addNotPzUserBill(Long pink_id);


}
